#!/usr/bin/python
# -*-coding: UTF-8 -*-
"""
# Time: 2024/5/12 8:44
# @Author: 修养
# @Project_name: PROJECT_NAME
"""

print("~~~~~~~~~~~~~~~~~~字典~~~~~~~~~~~~~~~~~~~")
#  ~~~~~~~~~~~~~~字典 ~~~~~~~~~~~~~~
# grades = {'语文': 100, '数学': '130', '英语': 120, '物理化': '210'}
# print(grades)
# # 添加键值对
# grades['政治'] = 70
# print("新增键值对后的字典：", grades)
# # 更新键值对
# grades['数学'] = 135
# # 更新列表，有则更新。无则插入
# grades.update({'语文': 120, '历史': 78})
# print(grades)
# # 弹出键值对并返回value值
# print(grades.pop('历史'))
# print(grades)
# # 删除键值对
# del grades['政治']
# print(grades)


people = {"name": "张无忌", "province": "陕西省", "age": 28,
          "kungfu": "九阳神功"}
print("输出人物信息：", people)
# 添加键值对
people["gender"] = "男"
# 更新键值对
people["kungfu"] = "乾坤大挪移"
# 有则更新，无则插入
people.update({"province": "山西省", "marry": False})
print("输出变更后的人物信息：", people)
# 弹出键值对，并返回value值，若无该键值对，则报错
value = people.pop("kungfu")
print("弹出键值对的值：", value)
del people["marry"]
print("输出删除键值对后的人物信息：", people)

# print("~~~~~~~~~~~~~~~~~~2222222字典的遍历~~~~~~~~~~~~~~~~~~~")
# # 得到字典key组成的列表
# print("字典所有key组成的列表：", grades.keys())
# # 得到字典value组成的列表
# print("字典所有value组成的列表：", grades.values())

# 输出键对于的值
# print('语文成绩：', grades['语文'])
# print('数学成绩：', grades.get('数学'))
#
# for key, value in grades.items():
#     print(f"科目：{key}", f"成绩：{value}")

# 得到字典key组成的列表
print("字典所有key组成的列表：", people.keys())
# 得到字典value组成的列表
print("字典所有value组成的列表：", people.values())
# 输出键值对对应的值
print("人物姓名：", people["name"])
print("人物年龄：", people.get("age"))
for key, value in people.items():
    print("key: ", key, ", value: ", value)

# print('~~~~~~~~~~~~~~元组 ~~~~~~~~~~~~~~')
# #  ~~~~~~~~~~~~~~元组 ~~~~~~~~~~~~~~
# balls = ('篮球', '足球', '羽毛球', 16)
# print(balls)
# print(type(balls))
#
# print(balls.index('足球'))
#
sports = ('篮球', '足球', '跑步', '跳远')
print("元组长度：", len(sports))
print("索引为1的元素：", sports[1])
for sport in sports:
    print(sport)